<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>禧乐仓连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<script type="text/javascript" src="<%=request.getContextPath()%>/conf_files/js/HeadQInvenFlow.js?v1.18"></script>
<LINK href="<%=request.getContextPath()%>/conf_files/css/qxbaby_css.css" type=text/css rel=STYLESHEET>
<script>


//variable to identify it is form submit or close the page
var formSubmit = false;
var P_NUMBER = 2;
var N_PRINT = 1;
var P_DISCOUNT = 3;
var index = 0;

//constants
var SALES_ORDER = 1;
var RETURN_ORDER = 2;

var errorIndexes = new Array();

document.onkeydown = BSkeyDown; 
function BSkeyDown(e){

	 var ieKey = event.keyCode;
	 //enter key is pressed 
	 if (ieKey==13){
	   if (event.srcElement.id.substring(0,7)=="barcode"){
           var index_trigger = event.srcElement.id.substring(7); 

		   var currentBarcode =$("#barcode"+index_trigger).val();
	       event.returnValue=false;
	
	       retrieveProductByBarcode(index_trigger,"" , currentBarcode);
	   } else if (event.srcElement.id.substring(0,11)=="productCode"){
		   var index_trigger = event.srcElement.id.substring(11);
		   event.returnValue=false;
		   searchProductsProductCode(index_trigger);
	   }else
		   event.returnValue=false;
	    
	 //back space key
	 }  else if (ieKey==8){
		    if((event.srcElement.tagName.toLowerCase() == "input" && event.srcElement.readOnly != true) || event.srcElement.tagName.toLowerCase() == "textarea"){
		        event.returnValue = true; 
		    } else
		    	event.returnValue = false;
	 }
} 


/**
 * user input the product code and press enter
 */
function searchProductsProductCode(index_trigger){
	var productCode = $.trim($("#productCode" +index_trigger).val());
	var storeId = $("#storeId").val();
	if (validateProductCodeInput(productCode)){
	    var params= "formBean.productBarcode.product.productCode=" + productCode + "&formBean.storeId=" + storeId + "&formBean.indexPage=" + index_trigger + "&formBean.fromSrc=1"; 
    
	    var url = encodeURI(encodeURI("productJSPAction!scanByProductCodeHeadq?" +params)) ; 
		
	    window.open(url,'新窗口','height=530, width=700, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');    
	}
}

/**
 * retrieve the product by input barcode
 */
function retrieveProductByBarcode(index_trigger, suffix, currentBarcode){
	if (validateRowInput(index_trigger,currentBarcode)){		
		var storeId = $("#storeId").val();
	    var params= "formBean.pb.barcode=" + currentBarcode + "&formBean.indexPage=" + index_trigger+ "&formBean.storeId="+storeId ; 
	    $.post("action/headqInventoryFlowJSONAction!scanByBarcodeInvenFlowOrder",params, backRetrievePByBarcodeProcess,"json");

	}
}
function backRetrievePByBarcodeProcess(dataReturn){
	var returnCode = dataReturn.returnCode;
	var data = dataReturn.returnValue;
	var index_c = data.indexC;
    

	if (returnCode != SUCCESS){
		alert("无法找到对应货品.请检查条码，重新输入!");

		clearRowCells(index_c);
	}else{
		var productIdInput =  $("#productId" +index_c);  
       	var unitInput =  $("#unit" +index_c);  
    	var brandInput =  $("#brand" +index_c);
    	var categoryInput = $("#category" +index_c);
    	var productCodeInput = $("#productCode"+index_c); 
    	var quantityInput =  $("#quantity"+index_c); 
    	var barcodeInput = $("#barcode"+index_c); 
    	var yearInput = $("#year"+index_c); 
    	var quarterInput = $("#quarter"+index_c); 
    	var inventoryInput = $("#inventoryQ"+index_c); 
    	var colorInput = $("#color"+index_c); 
    	var salesPriceInput = $("#salesPrice" + index_c);
    	var totalCostInput = $("#totalCost" + index_c);
    	
		var barcode = dataReturn.returnValue.pb.barcode;
		var productId = dataReturn.returnValue.pb.id;
		var product = dataReturn.returnValue.pb.product;
		var productCode = dataReturn.returnValue.pb.product.productCode;
		var brand = dataReturn.returnValue.pb.product.brand.brand_Name;
		var category = dataReturn.returnValue.pb.product.category.category_Name;  // 货品类别
		var unit = dataReturn.returnValue.pb.product.unit;
		var quantity = 1;
		var year = dataReturn.returnValue.pb.product.year.year;
		var quarter = dataReturn.returnValue.pb.product.quarter.quarter_Name;
		var inventoryQ = dataReturn.returnValue.inventoryLevel;
		var color = dataReturn.returnValue.pb.color;
		var colorName = "";
		if (color != null)
    		colorName = color.name;
		var salesPrice = dataReturn.returnValue.pb.product.salesPrice;
		var totalCost = quantity * salesPrice;

		productIdInput.attr("value",productId);
		barcodeInput.attr("value",barcode);
		productCodeInput.attr("value",productCode);
		unitInput.attr("value",unit);
    	brandInput.attr("value",brand); 
    	categoryInput.attr("value",category);
    	quantityInput.attr("value",quantity); 
    	yearInput.attr("value",year); 
    	quarterInput.attr("value",quarter); 
    	inventoryInput.attr("value", inventoryQ);
    	colorInput.attr("value", colorName);
    	salesPriceInput.attr("value", salesPrice);
    	totalCostInput.attr("value", totalCost);
    	
    	//if the user just changed the original barcode information
    	//then no need to add the index by one
    	if (index_c == index){
    	   addNewRow();
    	} else
    		$("#barcode"+index).focus(); 
    	
    	calculateTotal();
    	
    	var row = $("#orderRow"+index_c);
    	row.css('background-color', '');
	}
	
}


/**
 * to validate whether the product is selected or not
 */
function validateRowInput(index_trigger,currentBarcode){
//	var currentBarcode =$("#barcode"+index_trigger).val();

	if (currentBarcode.length != 12){
		alert(currentBarcode + " 不是一个正常条形.请重新输入.");
		clearRowCells(index_trigger);
		return false;
    } else {
		for (var i = 0; i < index; i++){
			if (i != index_trigger){
				var barcodeInput =  $("#barcode"+i);
		
				if (currentBarcode == barcodeInput.val()){
					var currentQ = $("#quantity" +i).val();
					$("#quantity" +i).attr("value" , parseInt(currentQ) + 1);
					
					calculateTotal();
					
					$("#barcode"+index).attr("value",""); 
			    	$("#barcode"+index).focus(); 
					
					return false;
				}
			}
		}
    }
	return true;
}

/**
 * to validate the product code input
 */
function validateProductCodeInput(productCode){
	if (productCode.length <= 1){
       alert("输入的货号太短");
       return false;
	}
	return true;
}

/**
 * to validate whether the product is selected or not
 * this is called from child
 */
function validateRowInputFromChild(currentBarcode){
	for (var i = 0; i < index; i++){
			var barcodeInput =  $("#barcode"+i);
			if (currentBarcode == barcodeInput.val()){

				var currentQ = $("#quantity" +i).val();
				$("#quantity" +i).attr("value" , parseInt(currentQ) + 1);
				
				calculateTotal();
				
				return false;
			}
	}
	return true;
}


/**
 * to clear the corresponding row's data
 */
function clearRowCells(index_c){
	//clear the cell
	$("#productId" +index_c).attr("value","");  
   	$("#unit" +index_c).attr("value","");  
	$("#brand" +index_c).attr("value","");   
	$("#productCode"+index_c).attr("value",0); 
	$("#quantity"+index_c).attr("value",0); 
	$("#comment"+index_c).attr("value",""); 
	$("#barcode"+index_c).attr("value",""); 
	$("#year"+index_c).attr("value",""); 
	$("#quarter"+index_c).attr("value",""); 
	$("#inventoryQ"+index_c).attr("value",""); 
	calculateTotal();
}


function calculateTotal(){
	var quantity_t =0;
	var inventory_t = 0;
	var totalCostOrder = 0;

	for (var i = 0; i <= index; i++){
	   	var quantityInput =  $("#quantity"+i); 
	   	var inventoryInput =  $("#inventoryQ"+i); 
	   	var salesPriceInput = $("#salesPrice"+i); 
	   	var totalCostInput = $("#totalCost"+i); 
        if (quantityInput.val()!= undefined && quantityInput.val()!="" ){
		   quantity_t += parseInt(quantityInput.val());
        }
        if (inventoryInput.val()!= undefined && inventoryInput.val()!=""){
        	inventory_t += parseInt(inventoryInput.val());
        }
        if (quantityInput.val()!= undefined && quantityInput.val()!="" && salesPriceInput.val()!= undefined && salesPriceInput.val()!=""){
        	var totalCost = parseInt(quantityInput.val()) * salesPriceInput.val();
        	totalCostInput.attr("value", totalCost);
        	totalCostOrder += totalCost;
        }
	}

   	$("#totalQuantity").attr("value",quantity_t); 
   	$("#totalInventoryQ").attr("value",inventory_t); 
   	
   	$("#totalCostOrder").attr("value",totalCostOrder); 
}



function addNewRow(){
    index = index +1;
	var pre_index = index -1;
	$("#viewIcon"+pre_index).show();
	$("#delIcon"+pre_index).show();
    var str = "";
    str += "<tr class='InnerTableContent' id='orderRow"+index+"'>";   
    str += "<td height='25'>"+(index +1)+"</td>";  
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.barcode' id='barcode"+index+"' size='13'/>" +
               "<input type='hidden' name='formBean.flowOrder.productList["+index+"].productBarcode.id' id='productId"+index+"' size='13'/></td>";  
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.productCode' id='productCode"+index+"' size='13'/></td>";  
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.color.name' id='color"+index+"' size='5'/></td>"; 
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.brand.brand_Name' id='brand"+index+"'  size='17' readonly='readonly'/></td>";
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.category.category_Name' id='category"+index+"'  size='17' readonly='readonly'/></td>"; 
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.year.year' id='year"+index+"'  size='4' readonly='readonly'/></td>"; 
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.quarter.quarter_Name' id='quarter"+index+"'  size='4' readonly='readonly'/></td>"; 
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.unit' id='unit"+index+"' size='4' readonly='readonly'/></td>";  
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].productBarcode.product.salesPrice' id='salesPrice"+index+"'  size='2' readonly='readonly'/></td>";     
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].quantity' id='quantity"+index+"'  size='2' onchange='calculateTotal("+index+")' onkeypress='return is_number(event);'/></td>";  
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].totalCost' id='totalCost"+index+"'  size='2' readonly='readonly'/></td>"; 
    str += "<td><input type='text' name='formBean.flowOrder.productList["+index+"].inventoryQ' id='inventoryQ"+index+"' readonly size='2' onchange='calculateTotal("+index+")' onkeypress='return is_number(event);'/></td>";  
    str += "<td><div id='viewIcon"+index+"' style='display:none'><img src='"+baseurl+"/conf_files/web-image/search.png' border='0'  onclick='viewImgK(\""+index +"\");' style='cursor:pointer;'/></div></td>";  
    str += "<td><div id='delIcon"+index+"' style='display:none'><img src='"+baseurl+"/conf_files/web-image/delete.png' border='0'  onclick='deleteRow(\"orderRow"+index +"\");' style='cursor:pointer;'/></div></td>";  
    str += "</tr>";   

    $("#orderTablebody").append(str);

    //freeze the previous row
    var barcodeInput = $("#barcode"+pre_index);
    barcodeInput.attr("readonly",true);
 
    var productCodeInput = $("#productCode"+pre_index);
    productCodeInput.attr("readonly",true);
    
	$("#barcode"+index).focus(); 
}


/**
 * 删除
 */
function deleteRow(rowID){	
	$("#"+rowID).remove(); 
 	calculateTotal();
}

/**
 * 根据条码查看退换货品的图片
 * @param rowID
 * @returns
 */
function viewImgK(rowID){
	var barcode =  $("#barcode" + rowID).val();  
	viewImg(barcode);
}



function deleteOrder(){
	if (confirm("你确定删除此单据吗?")){
		   formSubmit = true;
		   document.chainInventoryFlowForm.action = "action/headqInventoryFlowJSPAction!deleteOrder";
		   document.chainInventoryFlowForm.submit();
	}
}

//可以放进js文件
function downloadOrder(){
	
    document.chainInventoryFlowForm.action="action/headqInventoryFlowJSPAction!downloadFlowOrder";
    document.chainInventoryFlowForm.submit();
}

/**
 *  单据过账
 */
function saveFinal(){
	if (validateInvenFlowForm()){
		   formSubmit = true;
		   document.chainInventoryFlowForm.action = "action/headqInventoryFlowJSPAction!saveToFinal";
		   document.chainInventoryFlowForm.submit();
	}
}



/**
 * actions  保存草稿
 */
function saveDraft(){
	if (validateInvenFlowForm()){
	   formSubmit = true;
	   document.chainInventoryFlowForm.action = "action/headqInventoryFlowJSPAction!saveToDraft";
	   document.chainInventoryFlowForm.submit();
	}
}

function validateInvenFlowForm(type){
	  if (confirm("你确认提交单据?")){

			var error = "";

			var hasChar_q = false;

			for (var i = 0; i < index; i++){

				var q = $("#quantity" + i).val();

				if (q != undefined){
					if (isNaN(q) || q==0){
						hasChar_q = true;
						errorIndexes.push(i);
					}
				}
			}
			
			if (hasChar_q)
				error += "数量 - 必须为大于0的整数. 请检查后重新输入!\n";

			if (error != ""){
				for (var i =0; i < errorIndexes.length; i++){
					$("#orderRow" + errorIndexes[i]).css('background-color', '#EE8553');
				}
				
				alert(error);
				return false;
			}else{
				var totalQ = $("#totalQuantity").val();
				if (totalQ =="" || totalQ==0){
					alert("请输入货品后再保存单据!");
					return false;
				} 
              return true;
			}
	    } else {
	    	return false;
	    }
}

$(document).ready(function(){
	parent.$.messager.progress('close'); 
});
var baseurl = "<%=request.getContextPath()%>";
index = parseInt("<s:property value='formBean.flowOrder.productList.size()'/>");



</script>
</head>
<body>

    <s:form action="/action/inventoryFlowAction!saveToDraft" method="POST" name="chainInventoryFlowForm" id="chainInventoryFlowForm" theme="simple">
	<s:hidden name="formBean.flowOrder.type"/>  
	<s:hidden name="formBean.flowOrder.id"/>   
	<s:hidden name="formBean.flowOrder.status"/> 
    <table width="85%" align="center"  class="OuterTable">
	    <tr><td>
	         <div class="errorAndmes"><s:actionerror cssStyle="color:red"/><s:actionmessage cssStyle="color:blue"/></div>
			 <table width="100%" border="0">
			    <tr>
			       <td height="50" colspan="7">
				   	 <table width="100%" border="0">
				       <tr class="PBAOuterTableTitale">
				         <td height="32" colspan="4">
				              	<s:property value="formBean.flowOrder.typeHQS"/><p/>
				              	- 当电脑库存大于实际盘点库存,请建报损单<br/>
				              	- 当电脑库存小于实际盘点库存,请建报溢单
				         </td>
			           </tr>
				       <tr class="InnerTableContent">
				         <td width="234" height="32">创建人:<s:property value="formBean.flowOrder.creator.name"/></td>
				         <td width="160">日期:<s:property value="formBean.flowOrder.orderDate"/></td>
				         <td width="400">状态:<s:property value="formBean.flowOrder.statusS"/></td>
				         <td width="104"><strong>仓库：</strong></td>
				         <td width="200">
				         		<s:select name="formBean.flowOrder.storeId" size="1" id="storeId" list="uiBean.stores" listKey="id" listValue="name"  />
				         </td>
				       </tr>
				     </table></td>
			    </tr>
			    <tr class="InnerTableContent">
			      <td colspan="7"><hr width="100%" color="#FFCC00"/></td>
			    </tr>
			    <tr>
			      <td colspan="7">
			            <!-- table to display the product information -->
						<table width="100%"  align="left" class="OuterTable" id="org_table">
						  <tr class="PBAInnerTableTitale">
						    <th width="21">&nbsp;</th>
						    <th width="100" height="35">条形码</th>
						    <th width="100">货号/名称</th>
						    <th width="40">颜色</th>
						    <th width="110">品牌</th>
						    <th width="90">货品类别</th>
						    <th width="40">年份</th>
						    <th width="40">季度</th>
						    <th width="40">单位</th>
						    <th width="40">成本单价<br/>A</th>
						    <th width="39">纠正数量<br/>B</th>
						    <th width="40">总成本价<br/>A*B</th>
						    <th width="39">库存</th>
						    <th width="20">图片</th>
						    <th width="20"></th>
						  </tr>
						  <tbody id="orderTablebody">
						      <s:iterator value="formBean.flowOrder.productList" status = "st" id="orderProduct" >
						  		<tr class="InnerTableContent" id="orderRow<s:property value="#st.index"/>">   
							      <td height="25"><s:property value="#st.index +1"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.barcode" id="barcode<s:property value="#st.index"/>" size="13" value="<s:property value="#orderProduct.productBarcode.barcode"/>"/>
							          <input type="hidden" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.id" id="productId<s:property value="#st.index"/>" size="13" value="<s:property value="#orderProduct.productBarcode.id"/>"/>
							      	  <input type="hidden" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].id" size="13" value="<s:property value="#orderProduct.id"/>"/>
							      </td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.productCode" id="productCode<s:property value="#st.index"/>" size="13" value="<s:property value="#orderProduct.productBarcode.product.productCode"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.color.name" id="color<s:property value="#st.index"/>"  size="5" value="<s:property value="#orderProduct.productBarcode.color.name"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.brand.brand_Name" id="brand0<s:property value="#st.index"/>"  size="17" readonly="readonly" value="<s:property value="#orderProduct.productBarcode.product.brand.brand_Name"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.category.category_Name" id="category<s:property value="#st.index"/>"  size="17" readonly value="<s:property value="#orderProduct.productBarcode.product.category.category_Name"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.year.year" id="year<s:property value="#st.index"/>"  size="4" readonly="readonly" value="<s:property value="#orderProduct.productBarcode.product.year.year"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.quarter.quarter_Name" id="quarter<s:property value="#st.index"/>"  size="4" readonly="readonly" value="<s:property value="#orderProduct.productBarcode.product.quarter.quarter_Name"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.unit" id="unit<s:property value="#st.index"/>" size="4" readonly="readonly" value="<s:property value="#orderProduct.productBarcode.product.unit"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].productBarcode.product.salesPrice" id="salesPrice<s:property value="#st.index"/>" size="2" readonly="readonly" value="<s:property value="#orderProduct.productBarcode.product.salesPrice"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].quantity" id="quantity<s:property value="#st.index"/>"  size="2" onchange="calculateTotal()" onkeypress="return is_number(event);" value="<s:property value="#orderProduct.quantity"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].totalCost" id="totalCost<s:property value="#st.index"/>" size="2" readonly="readonly" value="<s:property value="#orderProduct.totalCost"/>"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value="#st.index"/>].inventoryQ" id="inventoryQ<s:property value="#st.index"/>"  size="2" onchange="calculateTotal()" onkeypress="return is_number(event);" value="<s:property value="#orderProduct.inventoryQ"/>"/></td>
							      <td><div id="viewIcon<s:property value="#st.index"/>"
														style="display: block">
														<img
															src="<%=request.getContextPath()%>/conf_files/web-image/search.png"
															border="0"
															onclick="viewImgK('<s:property value="#st.index"/>');"
															style="cursor: pointer;" />
													</div></td>	
							      <td><div id="delIcon<s:property value="#st.index"/>" style="display:block"><img src="<%=request.getContextPath()%>/conf_files/web-image/delete.png" border="0"  onclick="deleteRow('orderRow<s:property value="#st.index"/>');" style="cursor:pointer;"/></div>
								  </td>
							     </tr>
							   </s:iterator>  
						         <tr class="InnerTableContent" id="orderRow<s:property value='formBean.flowOrder.productList.size()'/>">   
							      <td height="25"><s:property value='formBean.flowOrder.productList.size() + 1'/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.barcode" id="barcode<s:property value='formBean.flowOrder.productList.size()'/>" size="13"/>
							      <input type="hidden" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.id" id="productId<s:property value='formBean.flowOrder.productList.size()'/>" size="13"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.productCode" id="productCode<s:property value='formBean.flowOrder.productList.size()'/>" size="13"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.color.name" id="color<s:property value='formBean.flowOrder.productList.size()'/>" size="5"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.brand.brand_Name" id="brand<s:property value='formBean.flowOrder.productList.size()'/>"  size="17" readonly="readonly"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.category.category_Name" id="category<s:property value='formBean.flowOrder.productList.size()'/>"  size="17" readonly/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.year.year" id="year<s:property value='formBean.flowOrder.productList.size()'/>"  size="4" readonly="readonly"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.quarter.quarter_Name" id="quarter<s:property value='formBean.flowOrder.productList.size()'/>"  size="4" readonly="readonly"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.unit" id="unit<s:property value='formBean.flowOrder.productList.size()'/>" size="4" readonly="readonly"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].productBarcode.product.salesPrice" id="salesPrice<s:property value='formBean.flowOrder.productList.size()'/>" size="2" readonly="readonly"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].quantity" id="quantity<s:property value='formBean.flowOrder.productList.size()'/>"  size="2" onchange="calculateTotal()" onkeypress="return is_number(event);"/></td>
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].totalCost" id="totalCost<s:property value='formBean.flowOrder.productList.size()'/>" size="2" readonly="readonly"/></td>					      
							      <td><input type="text" name="formBean.flowOrder.productList[<s:property value='formBean.flowOrder.productList.size()'/>].inventoryQ" id="inventoryQ<s:property value='formBean.flowOrder.productList.size()'/>" readonly size="2" onchange="calculateTotal()" onkeypress="return is_number(event);"/></td>
							     <td><div id="viewIcon<s:property value='formBean.flowOrder.productList.size()'/>" style="display: none">
										<img src="<%=request.getContextPath()%>/conf_files/web-image/search.png" border="0" onclick="viewImgK('<s:property value='formBean.flowOrder.productList.size()'/>');" style="cursor: pointer;" />
										</div></td>	
							      <td><div id="delIcon<s:property value='formBean.flowOrder.productList.size()'/>" style="display:none"><img src="<%=request.getContextPath()%>/conf_files/web-image/delete.png" border="0"  onclick="deleteRow('orderRow<s:property value='formBean.flowOrder.productList.size()'/>');" style="cursor:pointer;"/></div>
								  </td>
							     </tr> 
						  </tbody>
						  <tr class="PBAInnerTableTitale">
						    <th height="25" colspan="10" align='left'>合计</th>
						    <th align='left'><s:textfield name="formBean.flowOrder.totalQuantity" id="totalQuantity" readonly="true" size="2"/></th>
						    <th align='left'><s:textfield name="formBean.flowOrder.totalCost" id="totalCostOrder" readonly="true" size="2"/></th>
						    <th align='left'><s:textfield name="formBean.flowOrder.totalInventoryQ" id="totalInventoryQ" readonly="true" size="2"/></th>
						    <th></th>
						    <th></th>
						  </tr>
					     </table>
			      </td>
			    </tr>
			    <tr class="InnerTableContent">
			      <td height="30" colspan="7">
			            <!-- table to show the footer of the chain inventory flow -->
						<table width="100%" align="left" border="0">
						   <tr class="InnerTableContent">
					         <td height="40">备注</td>
					         <td colspan="2"><textarea name="formBean.flowOrder.comment" id="comment" rows="2" cols="50"><s:property value="formBean.flowOrder.comment"/></textarea></td>
				           </tr>
						  <tr class="InnerTableContent">
						    <td width="3%" height="25" align='left'>&nbsp;</td>
						    <td width="3%" align='left'>&nbsp;</td>
						    <td width="90%" align='left'>
						    
						    <!--  
							    <input type="button" value="存入草稿" onclick="saveDraft();" />
							    <input type="button" value="单据过账" onclick="saveFinal();"/>	
								<input type="button" value="删除单据" onclick="deleteOrder();"/>    -->
  
						
						     <s:if test="formBean.canSaveDraft">
						           <input type="button" value="存入草稿" onclick="saveDraft();" />
						      </s:if>
						      <s:if test=" formBean.canPost">
						           <input type="button" value="单据过账" onclick="saveFinal();"/>	
						      </s:if>
						      <s:if test="formBean.canDelete">
						            <input type="button" value="删除单据" onclick="deleteOrder();"/>	
						      </s:if>	
						      <s:if test="formBean.flowOrder.id > 0">
						            <input type="button" value="下载单据" onclick="downloadOrder();"/>	
						      </s:if>	

						      					
						    </td>
					      </tr>
					    </table>
				  </td>
			    </tr>
			    <tr class="InnerTableContent">
			      <td height="4" colspan="7"><hr width="100%" color="#FFCC00"/></td>
			    </tr>
			  </table>
	   </td></tr>
	 </table>
	 </s:form>

</body>
</html>